Skip to content

Conversation

@SunilKuravinakop
Copy link
Contributor

Same changes as in fix for #165276 except for changes in test case :

  1. remove unnecessary include in test to restore Ubuntu build.
    This is not needed as allocatable modifier is not applicable to the default clause in C/C++.
  2. Changes in CHECK statements to accommodate testing failure on toolchain
    builders at Google, Reported by Prabhu Rajasekaran.

Sunil Kuravinakop added 3 commits November 14, 2025 14:34
…de in test to restore Ubuntu build.

This is not needed as allocatable modifier is not applicable to the default clause in C/C++.
builders at Google, Reported by Prabhu Rajasekaran.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:openmp OpenMP related changes to Clang labels Nov 20, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 20, 2025

@llvm/pr-subscribers-clang

Author: None (SunilKuravinakop)

Changes

Same changes as in fix for #165276 except for changes in test case :

  1. remove unnecessary include in test to restore Ubuntu build.
    This is not needed as allocatable modifier is not applicable to the default clause in C/C++.
  2. Changes in CHECK statements to accommodate testing failure on toolchain
    builders at Google, Reported by Prabhu Rajasekaran.

Full diff: https://github.com/llvm/llvm-project/pull/168846.diff

2 Files Affected:

  • (modified) clang/lib/Sema/SemaOpenMP.cpp (+3-3)
  • (added) clang/test/OpenMP/parallel_default_variableCategory_codegen.cpp (+86)
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 81c591a00cfc6..31c8f0cd30c56 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -1364,15 +1364,15 @@ DSAStackTy::DSAVarData DSAStackTy::getDSA(const_iterator &Iter,
   DefaultDataSharingAttributes IterDA = Iter->DefaultAttr;
   switch (Iter->DefaultVCAttr) {
   case DSA_VC_aggregate:
-    if (!VD->getType()->isAggregateType())
+    if (!D->getType()->isAggregateType())
       IterDA = DSA_none;
     break;
   case DSA_VC_pointer:
-    if (!VD->getType()->isPointerType())
+    if (!D->getType()->isPointerType())
       IterDA = DSA_none;
     break;
   case DSA_VC_scalar:
-    if (!VD->getType()->isScalarType())
+    if (!D->getType()->isScalarType())
       IterDA = DSA_none;
     break;
   case DSA_VC_all:
diff --git a/clang/test/OpenMP/parallel_default_variableCategory_codegen.cpp b/clang/test/OpenMP/parallel_default_variableCategory_codegen.cpp
new file mode 100644
index 0000000000000..e94d590933c85
--- /dev/null
+++ b/clang/test/OpenMP/parallel_default_variableCategory_codegen.cpp
@@ -0,0 +1,86 @@
+// RUN: %clangxx -Xclang -verify -Wno-vla -fopenmp -fopenmp-version=60 -x c++ -S -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+int global;
+#define VECTOR_SIZE 4
+
+int main (int argc, char **argv) {
+  int i,n;
+  int x;
+
+  n = VECTOR_SIZE;
+
+  #pragma omp parallel masked firstprivate(x) num_threads(2)
+  {
+     int *xPtr = nullptr;
+     // scalar
+     #pragma omp task default(shared:scalar)
+     {
+       xPtr = &x;
+     }
+     #pragma omp taskwait
+
+     // pointer
+     #pragma omp task default(shared:pointer) shared(x)
+     {
+       xPtr = &x;
+     }
+     #pragma omp taskwait
+  }
+
+  int *aggregate[VECTOR_SIZE] = {0,0,0,0};
+  
+  #pragma omp parallel masked num_threads(2)
+  {
+     // aggregate
+     #pragma omp task default(shared:aggregate)
+     for(i=0;i<n;i++) {
+       aggregate[i] = &x;
+     }
+     #pragma omp taskwait
+
+     #pragma omp task default(shared:aggregate) shared(x)
+     for(i=0;i<n;i++) {
+       aggregate[i] = &x;
+     }
+     #pragma omp taskwait
+
+     // all
+     #pragma omp task default(shared:all)
+     for(i=0;i<n;i++) {
+       aggregate[i] = &x;
+     }
+     #pragma omp taskwait
+  }
+}
+
+#endif
+
+// CHECK-LABEL: define {{.*}}main.omp_outlined{{.*}}
+// CHECK: store ptr null, ptr{{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
+// CHECK: ret void
+//
+// CHECK: define {{.*}}main.omp_outlined{{.*}}
+// CHECK: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
+// CHECK: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
+// CHECK: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}getelementptr {{.*}}
+// CHECK-NEXT: store ptr {{.*}}
+// CHECK-NEXT: {{.*}}call{{.*}}__kmpc_omp_task_alloc{{.*}}
+// CHECK: ret void

@github-actions
Copy link

🐧 Linux x64 Test Results

  • 111348 tests passed
  • 4430 tests skipped

@chandraghale chandraghale self-requested a review November 21, 2025 05:06
Copy link
Contributor

@chandraghale chandraghale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix has been already reviewed from PR165276 . Testcase LGTM.

@chandraghale chandraghale merged commit 0a231c9 into llvm:main Nov 21, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:openmp OpenMP related changes to Clang clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants